package com.ease.integration.ejb2;

import javax.ejb.MessageDrivenContext;

import org.apache.commons.lang.StringUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
import org.springframework.ejb.support.AbstractJmsMessageDrivenBean;

/**
 * 
 * @author nathanleewei
 * 
 */
public abstract class SpringMessageDrivenBean extends AbstractJmsMessageDrivenBean implements SpringEnterpriseBean {

	/**
	 *
	 */
	private static final long serialVersionUID = -8215496029374627165L;

	public void setMessageDrivenContext(MessageDrivenContext messageDrivenContext) {
		super.setMessageDrivenContext(messageDrivenContext);
		setBeanFactoryLocator(ContextSingletonBeanFactoryLocator.getInstance(BEANS_REFERENCE_XML_NAME));
		setBeanFactoryLocatorKey(BEAN_FACTORY_LOCATOR_KEY);
	}

	protected String getBeanDefinitionNames() {
		String[] names = ((ApplicationContext) getBeanFactory()).getBeanDefinitionNames();
		return "\t" + StringUtils.join(names, "\n\t");
	}

}
